package com.IO;

import java.io.*;
import java.util.Properties;
import java.util.Set;

public class PrintJava {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader("D:\\下载\\file\\file5\\file1\\CopyJava.java"));
        PrintWriter pw = new PrintWriter(new FileWriter("D:\\下载\\file\\file5\\CopyJava.java"), true);
        String line;
        while ((line = br.readLine()) != null) {
            pw.println(line);
        }
        //prop();
        System.out.println("-----------------------------------");
        //myStore();
        System.out.println("-----------------------------------");
        myLoad();
        System.out.println("-----------------------------------");

    }

    private static void myLoad() throws IOException {
        Properties prop = new Properties();
        FileReader file=new FileReader("D:\\下载\\file\\file5\\java.txt");
        prop.load(file);
        Set<String> names=prop.stringPropertyNames();
        for (Object key : names) {
            Object value = prop.get(key);
            System.out.println(key + ",  " + value);
        }
        file.close();
    }

    private static void myStore() throws IOException {
        Properties prop = new Properties();
        FileWriter file=new FileWriter("D:\\下载\\file\\file5\\java.txt",true);
        prop.setProperty("itheima004","林青霞");
        prop.setProperty("itheima005","张曼玉");
        prop.setProperty("itheima006","王祖贤");
        prop.store(file,null);
        file.close();
    }



    private static void prop() {
        Properties prop = new Properties();
        prop.put("itheima001", "林青霞");
        prop.put("itheima002", "张曼玉");
        prop.put("itheima003", "王祖贤");
        Set<Object> set = prop.keySet();
        for (Object key : set) {
            Object value = prop.get(key);
            System.out.println(key + ",  " + value);
        }
        prop.setProperty("itheima002", "张曼玉5");
        String v = prop.getProperty("itheima002");
        System.out.println("itheima002" + v);
        Set<String> names = prop.stringPropertyNames();
        for (Object key : names) {
            Object value = prop.get(key);
            System.out.println(key + ",  " + value);
        }

    }
}
